package serializer;

import com.alibaba.fastjson.JSON;
import constant.SerializerAlgorithm;

/**
 * @author Admin
 */
public class JSONSerializer implements Serializer {
  @Override
  public byte getSerializerAlgorithm() {
    return SerializerAlgorithm.JSON;
  }

  @Override
  public byte[] serialize(Object object) {
    return JSON.toJSONBytes(object);
  }

  @Override
  public <T> T deserialize(Class<T> klass, byte[] bytes) {
    return JSON.parseObject(bytes, klass);
  }
}
